import requests
from config import RunConfig

'''
任务管理-物探任务书
'''

def search_drill_task(para):
    '''
    分页查询钻孔任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/drill/page?page=1&perPage=10",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def search_exploration_task(para):
    '''
    分页查询勘探任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/explore/page?page=1&perPage=10",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def delete_drill_task(para):
    '''
    删除钻孔任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + f"/task/drill/{id}",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def search_wlkt_task(name="", project_code="", property="",project_type_id="",project_manager=""):
    '''
    分页查询物探任务书
    :param name: 项目名称
    :param project_code: 项目编码
    :param property: 管控类型
    :param project_type_id: 勘测阶段
    :param project_manager: 项目负责人
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/page?page=1&perPage=10",
        headers=RunConfig.headers,
        json={
            "name": name,
            "projectCode": project_code,
            "property": property,
            "projectTypeId": project_type_id,
            "projectManager": project_manager
        },
        verify=False
    )
    return response


def exploration_unit_list(para):
    '''
    勘探单位下拉功能
    :param para:
    :return:
    '''
    response = requests.get(
        url=RunConfig.url + "/exploration/unit/list?name=&projectExtId=",
        headers=RunConfig.headers,
        verify=False
    )
    return response


def change_task_update(para):
    '''
    变更任务保存
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/change/update",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def change_task_info(para):
    '''
    变更任务查询
    :param para:
    :return:
    '''
    response = requests.get(
        url=RunConfig.url + f"/wt/task/change/info/{id}",
        headers=RunConfig.headers,
        verify=False
    )
    return response


def delete_wlkt(id):
    '''
    删除物探任务书
    :param id: 项目id
    :return:
    '''
    response = requests.get(
        url=RunConfig.url + f"/wt/task/delete/{id}",
        headers=RunConfig.headers,
        verify=False
    )
    return response


def task_info(id):
    '''
    查看任务书
    :param id: 项目id
    :return:
    '''
    response = requests.get(
        url=RunConfig.url + f"/wt/task/info/{id}",
        headers=RunConfig.headers,
        verify=False
    )
    return response


def phy_file_save(para):
    '''
    任务书文件保存
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/phy/file/save",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def update_drill_task(para):
    '''
    修改钻孔任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/task/drill/update",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def export_changed_task(para):
    '''
    变更任务下载
    :param para:
    :return:
    '''
    response = requests.get(
        url=RunConfig.url + f"/wt/task/change/export/{id}",
        headers=RunConfig.headers,
        verify=False
    )
    return response


def delete_explore_task(para):
    '''
    删除勘探任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + f"/task/explore/{id}",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def changed_task_list(para):
    '''
    变更任务查询列表
    :param para:
    :return:
    '''
    response = requests.get(
        url=RunConfig.url + f"/wt/task/change/list/{id}",
        headers=RunConfig.headers,
        verify=False
    )
    return response


def delete_cross_task(para):
    '''
    删除跨孔任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + f"/task/cross/{id}",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def export_task(id):
    '''
    物探任务书导出
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + f"/wt/task/export/{id}",
        headers=RunConfig.headers,
        json={},
        verify=False
    )
    return response


def update_cross_task(para):
    '''
    修改跨孔任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/task/cross/update",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def assign_task(para):
    '''
    分配任务
    :param para: [
                  {
                    "createUser": null,
                    "created": "1701792000",
                    "updateUser": null,
                    "updated": null,
                    "isDel": null,
                    "id": 253,
                    "taskId": 45,
                    "stageId": 69,
                    "type": 1,
                    "segmentId": 175,
                    "projectId": "67",
                    "submitCode": null,
                    "segmentName": "一测段",
                    "area": 0,
                    "engineerId": 7668,
                    "engineerName": "朱家垄特大桥",
                    "mileageStart": "23200",
                    "mileageEnd": "25200",
                    "methodId": 1,
                    "methodName": "天然场大地电磁",
                    "meaUnit": "km-点",
                    "workload": "2-81",
                    "workload1": "2",
                    "workload2": "81",
                    "isDouble": 1,
                    "schemeCode": "A",
                    "submitDate": "1703779200",
                    "other": "",
                    "implementType": 0,
                    "exploitMainId": 41,         # 实时类型
                    "exploitMain": "物探所",     # 实施主体
                    "leader": "蔡盛",            # 负责人
                    "projectName": null,
                    "areaName": null,
                    "leaderId": 779,
                    "crown": "DK",
                    "mileage": null,
                    "drillName": null,
                    "histogramUrl": null,
                    "drillNameTwo": null,
                    "histogramUrlTwo": null,
                    "crownTwo": null,
                    "mileageTwo": null,
                    "briefDesc": "",
                    "geoProTecReq": "断层",
                    "geoProTecReqs": null,
                    "geoProTecReqStr": null,
                    "distanceY": null,
                    "distanceX": null,
                    "distanceYTwo": null,
                    "distanceXTwo": null,
                    "createDate": "1701824231",
                    "middleAchievementUrls": null,
                    "projectManagerId": 779,
                    "projectManager": "蔡盛",
                    "property": null,
                    "methodMarkRed": 1,
                    "exploitMainMarkRed": 1,
                    "status": null,
                    "projectTypeId": null,
                    "projectCode": null,
                    "base": null,
                    "propertyName": null,
                    "projectTypeName": null
                  }
                ]
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/assign",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def search_cross_task(para):
    '''
    分页查询跨孔任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/cross/page?page=1&perPage=10",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def import_task(para):
    '''
    自揽任务书导入
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/wt/task/import?projectId=",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response


def update_explore_task(para):
    '''
    修改勘探任务
    :param para:
    :return:
    '''
    response = requests.post(
        url=RunConfig.url + "/task/explore/update",
        headers=RunConfig.headers,
        json=para,
        verify=False
    )
    return response
